#ifndef BANCO_H
#define BANCO_H

#include <vector>
#include <ctime>
#include <iostream>
#include <sstream>
#include <pthread.h>

#include "./fila.hpp"

#include "./caixa.h"
#include "./cliente.h"
#include "./settings.h"
#include "./logger.h"

#include "./bankStatStruct.h"

class bankSim
{
public:

	bankSim( const unsigned int, const float, const int, const int );

	virtual ~bankSim();

	void
	startWorking();

	unsigned int
	getInExpedientClientCount();

	unsigned int
	getOutExpedientClientCount();

	unsigned int
	getTotalClientCount();

	float
	getAvgTimingInQueue();

	unsigned int
	getTotalExtraTiming();

	unsigned int
	getTopInQeueTiming();

	unsigned int
	getLowerInQueueTiming();

	
protected:
	
	static void*
	doCare( void* );
	
private:

	static void
	sendMessage(const std::string);

	static bool
	temQTrabaia();

	static cliente*
	callNextOnQueue();

	static void
	wait( const time_t );
	
	static void
	statClient( cliente* );

	static bool
	jornadaDeTrabaio();

	void
	computeStats();

	void
	setCaixas( const unsigned int );
	
	settings*
	settingsInstance;

	// Elementos determinantes das threads
	std::vector<caixa>
	caixas;

	std::vector< pthread_t >
	atendimentos;

	static pthread_mutex_t 
	puxaFila;

	static pthread_mutex_t
	coutMutex;

	static fila<cliente*>
	filaDeEspera;

	static const time_t
	initTime;

	static struct bankStats
	statistics;

};


#endif /* BANCO_H */
